//
//  WPMsgViewModel.m
//  ZhongChouPingTai
//
//  Created by WeiPan on 16/4/13.
//  Copyright © 2016年 WPJoe. All rights reserved.
//

#import "WPWalletDetailViewModel.h"
#import "WPWalletDetailModel.h"

@implementation WPWalletDetailViewModel
+ (void)getWalletDetailWithPageNumber:(NSInteger)page SuccessBlock:(void (^)(NSArray *, NSInteger))success andWithFailureBlock:(void (^)(NSString *))failure {
    [NetWorkingManager postWithUrl:@"moveSoftware/MonetDetail.jhtml" requestParams:[NetWorkingManager paramsByAppendingUserInfo:@{@"memberid":[UserModel defaultUser].userID, @"pageNumber":@(page), @"pageSize":@(10)}] SuccessHandler:^(id responseObject) {
        if (responseObject[@"resultType"] && [responseObject[@"resultType"] intValue]) {
            NSMutableArray * resultArr = [NSMutableArray array];
            if ([responseObject[@"resultMsg"] isKindOfClass:[NSDictionary class]]) {
                for (NSDictionary * dcit in responseObject[@"resultMsg"][@"content"]) {
                    WPWalletDetailModel * model = [WPWalletDetailModel new];
//                    model.balance = dcit[@"balance"];
//                    model.memo = dcit[@"memo"];
//                    model.debit = dcit[@"debit"];
//                    model.createDate = dcit[@"createDate"];
                    [model setValuesForKeysWithDictionary:dcit];
                    [resultArr addObject:model];
                }
                success(resultArr, [responseObject[@"resultMsg"][@"totalPages"] integerValue]);
            } else {
                success(@[], 1);
            }
        } else {
            failure(responseObject[@"resultMsg"]? responseObject[@"resultMsg"]:@"获取资金明细失败");
        }
    } failureHandler:^(NSError *error) {
        failure(error.localizedDescription);
    }];
}
@end
